<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="/WEB-INF/common/urls.jsp"/>
<html lang="zh-CN">
<head>
    <title>${applicationScope.PROJECT_NAME}-管理员图书添加</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no">
    <link rel="icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/ico">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/lib/bootstrap-5.3.0-alpha1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/global.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
    <script src="${pageContext.request.contextPath}/lib/bootstrap-5.3.0-alpha1-dist/js/bootstrap.bundle.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/jquery-3.5.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/toast-manager.js"></script>
    <style>
    </style>
    <script>
    </script>
</head>

<body>
<header class="navbar navbar-expand-lg navbar-dark bg-body-secondary">
    <div class="container-fluid">
        <a class="navbar-brand navbar-logo" href="#">
            <svg class="logo" width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
                <path d="M10,5 L30,5 L35,10 L35,35 L5,35 L5,10 L10,5" fill="none" stroke="#1E88E5" stroke-width="2"/>
                <path d="M10,5 L10,10 L5,10" fill="none" stroke="#1E88E5" stroke-width="2"/>
                <path d="M12,15 L28,15 M12,20 L28,20 M12,25 L28,25 M12,30 L28,30" stroke="#1E88E5" stroke-width="1.5"/>
            </svg>
            <span>${applicationScope.PROJECT_NAME}</span>
        </a>
    </div>
</header>

<main class="main">
    <!-- 侧边栏 -->
    <jsp:include page="sidebar.jsp"/>
    <!-- 主体部分 -->
    <div class="main-content">
        <div class="mb-3 text-secondary font-size-14px">
            <p>
                为确保数据的完整性，图书及其类别信息的管理，包括添加、修改和删除操作，应当严格遵循系统界面提供的规范流程。严禁以任何形式直接在数据库中手动操作记录。
            </p>
        </div>
        <form action="${adminUrl}${isAdd ? '/book_add' : '/book_edit'}" method="get" class="add-form col-lg-4"
              accept-charset="UTF-8">

            <c:if test="${!isAdd}">
                <div class="mb-3">
                    <label for="input1" class="form-label">图书ID</label>
                    <input type="number" class="form-control" id="input1" name="bookId"
                           value="${not empty entity ? entity.bookId : ''}" readonly>
                </div>
            </c:if>
            <div class="mb-3">
                <label for="input2" class="form-label">图书标题</label>
                <input type="text" class="form-control" name="title" id="input2"
                       value="${not empty entity ? entity.title : ''}" required>
            </div>
            <div class="mb-3">
                <label for="input3" class="form-label">图书作者</label>
                <input type="text" class="form-control" name="author" id="input3"
                       value="${not empty entity ? entity.author : ''}">
            </div>
            <div class="mb-3">
                <label for="input4" class="form-label">出版社</label>
                <input type="text" class="form-control" name="publisher" id="input4"
                       value="${not empty entity ? entity.publisher : ''}">
            </div>
            <div class="mb-3">
                <label for="input5" class="form-label">出版日期</label>
                <input type="date" class="form-control" name="publishDate" id="input5"
                       value="${not empty entity ? entity.publishDate : ''}">
            </div>
            <div class="mb-3">
                <label for="input6" class="form-label">ISBN</label>
                <input type="text" class="form-control" name="isbn" id="input6"
                       value="${not empty entity ? entity.isbn : ''}">
            </div>
            <div class="mb-3">
                <label for="input7" class="form-label">分类号</label>
                <input type="text" class="form-control" name="classificationNumber" id="input7"
                       value="${not empty entity ? entity.classificationNumber : ''}">
            </div>
            <div class="mb-3">
                <label for="input8" class="form-label">图书类别</label>
                <select class="form-select" id="input8" name="categoryId">
                    <c:forEach var="category" items="${categoryList}">
                        <option value="${category.categoryId}"
                                <c:if test="${not empty entity and entity.categoryId == category.categoryId}">selected</c:if>>
                                ${category.categoryName}
                        </option>
                    </c:forEach>
                </select>
            </div>
            <div class="mb-3">
                <label for="input9" class="form-label">总副本数</label>
                <input type="number" class="form-control" name="totalCopies" id="input9"
                       value="${not empty entity ? entity.totalCopies : ''}">
            </div>
            <div class="mb-3">
                <label for="input10" class="form-label">可用副本数</label>
                <input type="number" class="form-control" name="availableCopies" id="input10"
                       value="${not empty entity ? entity.availableCopies : ''}">
            </div>
            <div class="mb-3">
                <button type="submit" class="btn btn-outline-primary">提交</button>
            </div>
        </form>
    </div>
</main>
<jsp:include page="/footer"/>
</body>
</html>